package org.sepheriel.airy2d.screen;

import org.sepheriel.airy2d.entity.Entity;
import org.sepheriel.airy2d.entity.Player;
import org.sepheriel.airy2d.math.Vec2;
import org.sepheriel.airy2d.physic.Rectangle;

/**
 * Represents a Camera used for rendering the scene
 * @author Sepheriel - Sascha Fitz
 */
public class Camera {
	
	public Rectangle viewport;
	float zoom;
	
	public Camera() {
		setViewport(new Rectangle(new Vec2(), 800, 600));
		zoom = 0;
	}
	
	public void positionCam(Vec2 pos) {
		this.getViewport().setPos(pos);
	}

	public Rectangle getViewport() {
		return viewport;
	}

	public void setViewport(Rectangle viewport) {
		this.viewport = viewport;
	}
	
	public Vec2 camToScreen(Vec2 p) {
		return new Vec2(p.getX()-viewport.getX(), p.getY()-viewport.getY());
	}
	
	public Vec2 getCenter() {
		return new Vec2(this.viewport.getCenter());
	}
	
	public void attach(Player play) {

		viewport.setPos(new Vec2(play.getPos().getX()-viewport.getWidth()/2, play.getPos().getY()-viewport.getHeight()/2));
	}
	

}
